package com.juc.completableFuture;

import java.util.Arrays;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;

public class CompletableFutureDemo2 {
	public static void main(String[] args) {
		List<Integer> list= Arrays.asList(1,2,3,4,5,6,7,8,9,10);
		CompletableFuture.supplyAsync(()->{
			return list.stream().reduce(Integer::sum).orElse(0);
		}).whenComplete((v,e)->{
			if(null == null) {
				System.out.println("result " + v);
			}
		}).exceptionally(e->{
			e.printStackTrace();
			return null;
		});
		try {
			TimeUnit.SECONDS.sleep(5);
		} catch (Exception e2) {
			e2.printStackTrace();
		}
	    
		
	}
}
